const query = require('./queryPromise')

const checkIsExistByName = (username) => {
  const sql = 'select * from cms_user where username = ?'
  return query(sql, username)
}

const insertUser = (username, password) => {
  const sql = 'insert into cms_user (username, password) values (?, ?)'
  return query(sql, username, password)
}

const userLogin = (username, password) => {
  const sql = 'select * from cms_user where username = ? and password = ?'
  return query(sql, username, password)
}

const userInfo = (userId) => {
  const sql = 'select * from cms_user where id = ?'
  return query(sql, userId)
}

module.exports = { insertUser, checkIsExistByName, userLogin, userInfo }
